import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import { plmPrjInfoListData } from '/@/api/quesLib/prj/plmPrjInfo';

const { t } = useI18n('sys.empUser');

const modalProps = {
  title: t('项目选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 60,
  schemas: [
    {
      label: t('项目名称'),
      field: 'projectname',
      component: 'Input',
    },
    {
      label: t('项目编码'),
      field: 'projectcode',
      component: 'Input',
    },
    {
      label: t('分类ID'),
      field: 'cmkindid',
      component: 'Input',
      show: false,
    },
  ],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('项目名称'),
    dataIndex: 'projectname',
    key: 'a.projectname',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('项目编码'),
    dataIndex: 'projectcode',
    key: 'a.projectcode',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('开始时间'),
    dataIndex: 'begintime',
    key: 'a.begintime',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('结束时间'),
    dataIndex: 'endtime',
    key: 'a.endtime',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('状态'),
    dataIndex: 'cstate',
    key: 'a.cstate',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('实际开始时间'),
    dataIndex: 'crealbegintime',
    key: 'a.crealbegintime',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('实际结束时间'),
    dataIndex: 'crealendtime',
    key: 'a.crealendtime',
    sorter: true,
    width: 130,
    align: 'left',
  },
  {
    title: t('分类ID'),
    dataIndex: 'cmkindid',
    key: 'a.cmkindid',
    sorter: true,
    width: 130,
    align: 'center',
  },
  {
    title: t('修改时间'),
    dataIndex: 'modifytime',
    key: 'a.modifytime',
    sorter: true,
    width: 130,
    align: 'left',
  },
];

const tableProps: BasicTableProps = {
  api: plmPrjInfoListData,
  beforeFetch: (params) => {
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'projectcode',
  itemName: 'projectname',
};
